package io.github.veigara.tcp.framework.factory;

/**
 * @author : zhouhx
 * @date : 2025/6/6 13:30
 */

import io.github.veigara.tcp.framework.protocol.*;
import io.github.veigara.tcp.framework.model.DeviceConnection;
import io.github.veigara.tcp.framework.model.DeviceType;

/**
 * 默认组件工厂
 */
public class DefaultDeviceComponentFactory implements DeviceComponentFactory {
    private final DeviceType deviceType;

    public DefaultDeviceComponentFactory(DeviceType deviceType) {
        this.deviceType = deviceType;
    }

    @Override
    public ProtocolHandler createProtocolHandler(DeviceConnection connection) {
        return new DefaultProtocolHandler(connection);
    }

    @Override
    public ProtocolDecoder<?> createDecoder() {
        return new DefaultProtocolDecoder();
    }

    @Override
    public ProtocolEncoder<?> createEncoder() {
        return new DefaultProtocolEncoder();
    }

    @Override
    public DeviceType getDeviceType() {
        return deviceType;
    }
}
